<%@ page pageEncoding="utf-8" import="java.util.*" %>
<%@ page import="DoMain.Food" %>
<%@ page import="Dao.CriteriaFood" %>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@page import="java.text.SimpleDateFormat"%>
<!doctype html>
<html lang="en">
  <head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">

    <title>菜品管理</title>
    <script type="text/javascript" src="script/jquery-3.3.1.js"></script>
    <script type="text/javascript">

		$(function(){
			
			$(".delete").click(function(){
				
				var content=$(this).parent().parent().find("td:eq(1)").text();
				var flag=confirm("确定要删除"+content+"的信息吗？");
				
				return flag;
				
			});	
		});
		
</script>
  </head>
  <body>
  <form action="queryFood.do">
<div class="form-group">
				 <label  class="col-sm-2 col-form-label">菜品名称:</label>
				<input type="text" name="foodName">
				 <label  class="col-sm-2 col-form-label">菜品描述:</label>
				<input type="text" name="foodDescription">
				</div>
			 <div class="form-group">
				<label  class="col-sm-2 col-form-label">菜品单价:</label>
				<input type="text" name="foodPrice">
				&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
				<input type="submit" class="btn btn-outline-danger" value="查询">
				&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
				<span>添加新菜品</span><a href="newFood.jsp">Add new Food</a></div>
  </form>
  
  <% 	
  		List<Food> foods=(List<Food>)request.getAttribute("foods"); 
  		
  		int index=1;
  %>
 
  <table class="table table-hover">

    <tr class="table-primary" align="center">
      <th scope="col" align="center">菜品编号</th>
      <th scope="col" align="center">菜品名称</th>
      <th scope="col" align="center">菜品描述</th>
      <th scope="col" align="center">菜品单价</th>
      <th scope="col" align="center">操作</th>
    </tr>


  <c:forEach items="${foods}" var="fo">
			<tr  class="table-light">
				<td class="table-success" scope="row" align="center"><%=index++%></td>
				<td class="table-success" scope="row" align="center">${fo.foodName}</td>
				<td class="table-warning" scope="row" align="center">${fo.foodDescription}</td>
				<td class="table-warning" scope="row" align="center">${fo.foodPrice}</td>
				<td align="center"><a href="editFood.do?foodNo=${fo.foodNo}">修改</a>|
					<a align="center" class="delete" href="deleteFood.do?foodNo=${fo.foodNo}">删除</a>
				</td>
			</tr>
			</c:forEach>

	

</table>
    <table align="center">
	<tr align="center">
    <td align="center" class="page-item"><a class="page-link" href="page.do?currentPage=1">首页</a></td>
    <td align="center" class="page-item"><a class="page-link" href="page.do?currentPage=1">1</a></td>
    <td align="center" class="page-item"><a class="page-link" href="page.do?currentPage=2">2</a></td>
    <td align="center" class="page-item"><a class="page-link" href="page.do?currentPage=3">3</a></td>
    <td align="center" class="page-item"><a class="page-link" href="page.do?currentPage=4">4</a></td>
    <td align="center" class="page-item"><a class="page-link" href="page.do?currentPage=5">5</a></td>
    <td align="center" class="page-item"><a class="page-link" href="page.do?currentPage=6">6</a></td>
    <td align="center" class="page-item"><a class="page-link" href="page.do?currentPage=7">7</a></td>
    <td align="center" class="page-item"><a class="page-link" href="page.do?currentPage=8">8</a></td>
    <td align="center" class="page-item"><a class="page-link" href="page.do?currentPage=9">9</a></td>
    <td align="center" class="page-item"><a class="page-link" href="page.do?currentPage=10">10</a></td>
    <td align="center" class="page-item"><a class="page-link" href="page.do?currentPage=11">尾页</a></td>
</tr>


</table>

  </body>
  </html>